//package com.itcam.cammydada.test;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//
///**
// * @author : Cammy.Wu
// * Description :
// */
//
//public class SseServlet extends HttpServlet {
//    @Override
//    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        resp.setContentType("text/event-stream");
//        resp.setCharacterEncoding("UTF-8");
//        resp.setHeader("Cache-Control", "no-cache");
//        resp.setHeader("Connection", "keep-alive");
//        PrintWriter writer = resp.getWriter();
//        for (int i = 0; i < 10; i++) {
//            writer.write("data: Message " + i + "\n\n");
//            writer.flush();
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        }
//        writer.close();
//    }
//}
